package com.blogs.tools;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.util.Log;

public class GetTextFromWeb {
	
	public static String Get(String url)
	{
		Log.v("RequestUrl", url);
		HttpResponse httpResponse;
		HttpEntity entry;
		InputStream inputStream=null;
		HttpGet hg=new HttpGet(url);	   
        HttpClient clien=new DefaultHttpClient();
      	String result="";
        try {
        	httpResponse=clien.execute(hg);
        	entry=httpResponse.getEntity();
        	inputStream=entry.getContent();
        	BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream));
        	String line="";
        	while((line=reader.readLine())!=null)
        	{
        		result=result+line;
        	}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        try {
        	if(inputStream!=null)
        	{
        		inputStream.close();
        	}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        Log.v("ReceiveData", result);
        return result;
	}
}
